package com.cat.yygh.hosp.controller.user;

import com.cat.yygh.common.result.R;
import com.cat.yygh.hosp.service.ScheduleService;
import com.cat.yygh.model.hosp.Schedule;
import com.cat.yygh.vo.hosp.ScheduleOrderVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/hosp")
public class UserScheduleController {
    @Autowired
    private ScheduleService scheduleService;
    @GetMapping("/getBookingScheduleRule/{hoscode}/{depcode}/{pageNum}/{pageSize}")
    public R getSchedulePage(@PathVariable String hoscode,
                             @PathVariable String depcode,
                             @PathVariable Integer pageNum,
                             @PathVariable Integer pageSize){
        Map<String,Object> map = scheduleService.getSchedulePage(hoscode,depcode,pageNum,pageSize);
        return R.ok().data(map);
    }
    @GetMapping("/findScheduleList/{hoscode}/{depcode}/{workdate}")
    public R getScheduleDetail(@PathVariable String hoscode,
                               @PathVariable String depcode,
                               @PathVariable String workdate){
        List<Schedule> detail = scheduleService.getScheduleDetail(hoscode,depcode,workdate);
        return R.ok().data("detail",detail);
    }
    @ApiOperation(value = "获取排班详情")
    @GetMapping("getSchedule/{id}")
    public R getScheduleList(
            @PathVariable String id) {
        Schedule schedule = scheduleService.getById(id);
        return R.ok().data("schedule",schedule);
    }
    //不建议 接口复用，建议 方法复用
    @GetMapping("/schedule/{scheduleId}")
    public ScheduleOrderVo getScheduleById(
            @PathVariable(value = "scheduleId") String scheduleId) {
        return scheduleService.getScheduleById(scheduleId);
    }
}
